from django.urls import path, re_path
from django.conf import settings
from django.views.static import serve
from django.conf.urls.static import static
from rest_framework.routers import DefaultRouter
from bookshop.views.about_users import users_view
from bookshop.views.about_books import books_view, Types
from bookshop.views.about_users import tables, login

router = DefaultRouter()
router.register("bookUserUrls", users_view.UserModelViewSet, basename="bookUserUrls"),
router.register("BooksUrls", books_view.BooksModelViewSet, basename="bookBooksUrls"),
router.register("TypesUrls", Types.TypesModelViewSet, basename="TypesUrls"),    # basename: 别称，外号
router.register("UserCollection", tables.UserCollectModelViewSet, basename="UserCollection"),
router.register("UserHistory", tables.UserHistoryModelViewSet, basename="UserHistory"),
router.register("UserBlackUrls", tables.UserBlackModelViewSet, basename="UserBlack"),
router.register("UserBookUrls", tables.UserBookModelViewSet, basename="UserBook"),
router.register("UserTypeUrls", tables.UserTypeModelViewSet, basename="UserBook"),

urlpatterns = [
    # path("book/", books_view.BookView.as_view()),                    # 书籍的增删改查
    # re_path(r'book/(?P<pk>\d+)/', books_view.BookDetailsView.as_view()),
    # path("types/", Types.TypesView.as_view()),                       # 书类型的增删改查
    # re_path(r'types/(?P<pk>\d+)/', Types.TypesDetailsView.as_view()),
    path('book/chazhao/', books_view.chazhao),                # 按书名泛查找（返回最符合的那一个）： method：post
    path('types/chazhao/', Types.chazhao),                   # 按类型查找返回该类型图书
    path('login/', login.login),
    path('check/', login.check)    # 更新用户状态
              ]
urlpatterns += router.urls